package com.project.base.baseproject.ModelManager.Models;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import io.realm.RealmObject;
import io.realm.annotations.PrimaryKey;
import io.realm.annotations.RealmClass;
import io.realm.annotations.Required;

/**
 * Created by mac on 2016/11/28.
 */
//用户类
public class User extends RealmObject {
    //用户guid
    @PrimaryKey
    @Expose(deserialize = true,serialize = true) private String user_guid;
    //用户名字
    @Expose(deserialize = true,serialize = true) private int id;
    //QQ
    @Expose(deserialize = true,serialize = true) private String name;
    //头像地址
    @Expose(deserialize = true,serialize = true) private String avatar;
    //扩展  自己加的属性
    @Expose(deserialize = true,serialize = true) private int currCompanyNo;

    //转换成json字符串 自己写可以防止null错误
    public static String jsonString(User user) {
        Gson gson = new Gson();
        Map userMap = new HashMap();
        userMap.put("id",user.id+"");
        userMap.put("user_guid",user.user_guid);
        userMap.put("name",user.name);
        userMap.put("avatar",user.avatar);
        //ex
        userMap.put("currCompanyNo",user.currCompanyNo+"");
        return gson.toJson(userMap,Map.class);
    }
    public String getUser_guid() {
        return user_guid;
    }
    public void setUser_guid(String user_guid) {
        this.user_guid = user_guid;
    }
    public int getId() {
        return id;
    }
    public void setId(int id) {
        this.id = id;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getName() {
        return name;
    }
    public String getAvatar() {
        return avatar;
    }
    public void setAvatar(String avatar) {
        this.avatar = avatar;
    }
    public int getCurrCompanyNo() {
        return currCompanyNo;
    }
    public void setCurrCompanyNo(int currCompanyNo) {
        this.currCompanyNo = currCompanyNo;
    }
}
